package com.excuse.excusebuilder.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.excuse.excusebuilder.R;
import com.excuse.excusebuilder.base.BaseActivity;
import com.excuse.excusebuilder.bean.Type;
import com.excuse.excusebuilder.presenter.AddOptionActivityPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AddOptionActivity extends BaseActivity implements View.OnClickListener, AddOptionActivityPresenter.IView {
    public static final String PARAM_TYPE = "param_type";
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.app_bar)
    AppBarLayout appBar;
    @BindView(R.id.option_edt)
    EditText optionEdt;
    @BindView(R.id.result_edt)
    EditText resultEdt;
    @BindView(R.id.add_btn)
    Button addBtn;
    private AddOptionActivityPresenter presenter;
    private Type type;


    @Override
    protected void initData() {
        presenter = new AddOptionActivityPresenter(this, this);
        type = (Type) getIntent().getSerializableExtra(PARAM_TYPE);
        initToolbar(toolbar, type.getName());
        addBtn.setOnClickListener(this);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_add_option;
    }

    @Override
    public void onClick(View v) {
        String optionStr = optionEdt.getText().toString().trim();
        String resultStr = resultEdt.getText().toString().trim();
        presenter.addOption(type,optionStr,resultStr);
    }

    @Override
    public void showRefreshing(boolean isShow) {

    }
}
